<?php

namespace App\Http\Requests;

use App\Exceptions\TeleException;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;

class NotifyCallUrlRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id'=>'required',
            'seqId'=>'required',
            'timestamp'=>'required',
            'virtualMobile'=>'required',
            'from'=>'required',
            'to'=>'required',
            'callStart'=>'required',
            'callAnswer'=>'required',
            'callEnd'=>'required',
            'mid'=>'required',
            'call'=>'required',
            'status'=>'required',
            'sign'=>'required'
        ];
    }
    protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator)
    {
        throw new TeleException($validator->errors()->first());
    }
}
